package diagUMLm;

import javax.swing.BorderFactory;
import javax.swing.CellRendererPane;
import javax.swing.JLabel;
import javax.swing.border.BevelBorder;

import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.swing.view.mxInteractiveCanvas;
import com.mxgraph.view.mxCellState;

public class Canevas extends mxInteractiveCanvas
{
	protected CellRendererPane rendererPane = new CellRendererPane();

	protected JLabel vertexRenderer = new JLabel();

	protected mxGraphComponent graphComponent;

	public Canevas(mxGraphComponent graphComponent)
	{
		this.graphComponent = graphComponent;

		vertexRenderer.setBorder(BorderFactory
				.createBevelBorder(BevelBorder.RAISED));
		vertexRenderer.setHorizontalAlignment(JLabel.CENTER);
		vertexRenderer.setBackground(graphComponent.getBackground()
				.darker());
		vertexRenderer.setOpaque(true);
	}

	public void drawVertex(mxCellState state, String label)
	{
		vertexRenderer.setText(label);
		// TODO: Configure other properties...

		rendererPane.paintComponent(g, vertexRenderer, graphComponent,
				(int) state.getX() + translate.x, (int) state.getY()
						+ translate.y, (int) state.getWidth(),
				(int) state.getHeight(), true);
	}

}

